package Thread;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public class MyThreadFactory implements ThreadFactory {
    private final AtomicInteger threadNamePrefix;
    private final static String threadName = "MyThread-";

    public MyThreadFactory(){
        this.threadNamePrefix = new AtomicInteger(1);
    }
    @Override
    public Thread newThread(Runnable r) {
        return new Thread(r,threadName + this.threadNamePrefix.getAndIncrement());
    }
}
